<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>系统管理-用户信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">登录名称</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="loginName" placeholder="请输入登录名称" /></label>
			<label class="layui-input-inline">用户姓名</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="userName" placeholder="请输入用户姓名" /></label>
			<label class="layui-input-inline">用户性别</label>
			<label class="layui-input-inline">
				<select name="userSex" id="userSex"></select>
			</label>
			<label class="layui-input-inline">手机号</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="userPhone" placeholder="请输入手机号" /></label>
			<label class="layui-input-inline">状态</label>
			<label class="layui-input-inline">
				<select name="status" id="status"></select>
			</label>
			<a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a>
			<a class="layui-btn layui-btn-normal addBtn" data-title="添加" data-url="/sysUser/getEntity">添加</a>
		</div>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class = "layui-btn cy-btnbg-edit layui-btn-sm" lay-event = "edit"> 编辑 </a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="reset">重置密码</a >
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'pageUtil', 'table', 'checkUtil', 'dateUtil', 'dialogUtil','baseUtil'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            table = layui.table,
            baseUtil = layui.baseUtil,
            checkUtil = layui.checkUtil,
            dialogUtil = layui.dialogUtil,
            pageUtil = layui.pageUtil;
        var tableIns = null;
        pageUtil.initDict("base_sex,base_status",
            function(dictData) {
                pageUtil.showDict($("#userSex"), pageUtil.aceeptDictContentList(dictData, "base_sex"), "请选择用户性别");
                pageUtil.showDict($("#status"), pageUtil.aceeptDictContentList(dictData, "base_status"), "请选择状态");
                var url = "/sysUser/page";
                var cols = [{
                    type: 'checkbox',
                    fixed: 'left'
                },
                    {
                        type: 'numbers',
                        title: '序号'
                    },
                    {
                        field: 'loginName',
                        title: '登录名称',
                        align: 'center'
                    },
                    {
                        field: 'userName',
                        title: '用户姓名',
                        align: 'center'
                    },
                    {
                        field: 'departName',
                        title: '所属部门',
                        align: 'center'
                    },
                    {
                        field: 'roleName',
                        title: '所属角色',
                        align: 'center'
                    },
                    {
                        field: 'userSex',
                        title: '用户性别',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'base_sex', d.userSex);
                        }
                    },
                    {
                        field: 'userPhone',
                        title: '用户手机号',
                        align: 'center'
                    },
                    {
                        field: 'status',
                        title: '状态',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'base_status', d.status);
                        }
                    },
                    {
                        field: 'sort',
                        title: '排序',
                        align: 'center'
                    },
                    {
                        field: 'lastLoginTime',
                        title: '最后登录时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            if(checkUtil.isEmpty(d.lastLoginTime)){
                                return "";
							}else{
                                return dateUtil.formatDate(new Date(d.lastLoginTime), "yyyy-MM-dd hh:mm:ss");
							}
                        }
                    },
                    {
                        field: 'ipAddress',
                        title: '最后登录ip地址',
                        align: 'center'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        field: 'updateTime',
                        title: '修改时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.updateTime), "yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: '操作',
                        width: 200,
                        templet: '#entityBar',
                        align: "center",
                        fixed: 'right'
                    }];
                tableIns = pageUtil.initDate(cols, url, true);
            });
        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/sysUser/getEntity?id=" + data.id);
                } else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/sysUser/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                } else if (layEvent === 'reset') {
                    dialogUtil.confirm('您确定要重置用户【'+data.userName+'】的登录密码吗？',function(){
                        baseUtil.postMethodResult( "/sysUser/resetPassword", {
                            "id": data.id
                        },function(data) {
                            dialogUtil.alert("密码重置为："+data);
                        });

                    },function(){
                    });
                }
            });
    })</script>
</body>

</html>